<template>
    <div class="agentList divBox">
      <el-card class="box-card" shadow="hover">
        <el-table
          v-loading="disLoading"
          :data="tableActivityList"
          style="width: 100%"
          size="mini"
          class="table"
          @selection-change="handleSelectionChange"
        >
          <!-- <el-table-column type="selection" min-width="55"></el-table-column> -->
          <el-table-column
            prop="id"
            label="ID"
            align="center"
            min-width="135"
          ></el-table-column>
          <el-table-column
            prop="name"
            label="活动名称"
            align="center"
            min-width="120"
          ></el-table-column>
          <el-table-column
            prop="urlLink"
            label="活动链接"
            align="center"
            min-width="120"
          ></el-table-column>
          <el-table-column
            prop="description"
            label="简介"
            align="center"
            min-width="120"
          ></el-table-column>
  
          <el-table-column label="操作" width="230" fixed="right" align="center">
            <template slot-scope="{ row }">
              <el-button type="text" size="small" @click="edit(row.id)"
                >选择活动</el-button>
              </el-dropdown>
            </template>
          </el-table-column>
        </el-table>
        <div class="spreadBox">
          <pagination
            v-show="pagination.total > 0"
            :total="pagination.total"
            :page.sync="pagination.page"
            :limit.sync="pagination.limit"
            :page-sizes="[10, 20, 30, 50]"
            @pagination="replyChange"
          />
        </div>
      </el-card>
    </div>
  </template>
  
  <script>
  import {
    getActivitieListApi,
    activitieDeleteApi,
    patchActivitieApi,
  } from "@/api/activity";
  import { mapGetters } from "vuex";
  export default {
    name: "Index",
    data() {
      return {
        grid: {
          xl: 5,
          lg: 7,
          md: 12,
          sm: 12,
          xs: 24,
        },
        disForm: {
          keyword: "",
          roleId: "",
        },
        pagination: {
          page: 1,
          limit: 10,
          total: 100,
        },
        tableActivityList: [],
        del: [],
        disLoading: false,
        disabled: true,
      };
    },
    beforeCreate() {},
    mounted() {
      this.getActivityList();
    },
    computed: {
      ...mapGetters(["customRouter"]),
    },
    methods: {
      /**
       * 行选中时
       */
      handleSelectionChange(val) {
        this.$set(
          this,
          "del",
          val.map((item) => item.id)
        );
        console.log(this.del);
        if (val.length > 0) this.$set(this, "disabled", false);
        else this.$set(this, "disabled", true);
      },
      /**
       * 获取活动列表
       */
      getActivityList() {
        getActivitieListApi({
          pageNumber: this.pagination.page,
          pageSize: this.pagination.limit,
          orderby: "Number desc",
          isShow: 1,
          isDel: -1,
        }).then((res) => {
          this.$set(this, "tableActivityList", res.data);
          this.pagination.total = res.head ? res.head.totalCount : 0;
        });
      },
      replyChange(reply) {
        this.$set(this.pagination, "page", reply.page);
        this.$set(this.pagination, "limit", reply.limit);
        console.log("pagination", this.pagination);
        this.getActivityList();
      },
      //选择活动id
      edit(id){
        console.log("id>>>>>>",id);
        this.$emit('getActivityList',id)
        this.$emit('close')
      }
    },
  };
  </script>
  
  <style lang="scss" scoped>
  .box-card{
    max-height: 500px;
    overflow-y: scroll;
  }
  .agentList {
    .taoBox_img {
      width: 36px;
      height: 36px;
      border-radius: 4px;
      overflow: hidden;
      cursor: pointer;
  
      img {
        width: 100%;
        height: 100%;
      }
    }
    .taoBoxs_img {
      // width: 36px;
      // height: 36px;
      border-radius: 4px;
      // overflow: hidden;
      cursor: pointer;
  
      img {
        margin-right: 5px;
        width: 36px;
        height: 36px;
      }
      video {
        margin-right: 5px;
        width: 50px;
        height: 50px;
      }
    }
  
    .el-dropdown-link {
      cursor: pointer;
      color: #409eff;
      font-size: 12px;
    }
  
    .el-icon-arrow-down {
      font-size: 12px;
    }
  }
  </style>
  
  <style lang="scss">
  .el-dialog.cusDialogCls,
  .el-dialog.editAgentDialogCls {
    max-width: 960px;
  }
  
  .el-dialog.promotionOrderDialogCls {
    max-width: 900px;
  }
  </style>